/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.agenda.model.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Ronildo
 */
@Entity
@Table(name = "AM_TB_PLAN_SAUD")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AmTbPlanSaud.findAll", query = "SELECT a FROM AmTbPlanSaud a"),
    @NamedQuery(name = "AmTbPlanSaud.findByCdPlanSaud", query = "SELECT a FROM AmTbPlanSaud a WHERE a.cdPlanSaud = :cdPlanSaud"),
    @NamedQuery(name = "AmTbPlanSaud.findByNmPlanSaud", query = "SELECT a FROM AmTbPlanSaud a WHERE a.nmPlanSaud = :nmPlanSaud")})
public class AmTbPlanSaud implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @Basic(optional = false)
    @Column(name = "CD_PLAN_SAUD")
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "seq_AM_TB_PLAN_SAUD")
    @SequenceGenerator(name="seq_AM_TB_PLAN_SAUD", sequenceName = "seq_AM_TB_PLAN_SAUD")
    private Integer cdPlanSaud;
    
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 40)
    @Column(name = "NM_PLAN_SAUD")
    private String nmPlanSaud;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "amTbPlanSaud")
    private Collection<AmTbMediPlanSaud> amTbMediPlanSaudCollection;
    @JoinColumn(name = "CD_CONV_MEDI", referencedColumnName = "CD_CONV_MEDI")
    @ManyToOne(optional = false)
    private AmTbConvMedi cdConvMedi;

    public AmTbPlanSaud() {
    }

    public AmTbPlanSaud(Integer cdPlanSaud) {
        this.cdPlanSaud = cdPlanSaud;
    }

    public AmTbPlanSaud(Integer cdPlanSaud, String nmPlanSaud) {
        this.cdPlanSaud = cdPlanSaud;
        this.nmPlanSaud = nmPlanSaud;
    }

    public Integer getCdPlanSaud() {
        return cdPlanSaud;
    }

    public void setCdPlanSaud(Integer cdPlanSaud) {
        this.cdPlanSaud = cdPlanSaud;
    }

    public String getNmPlanSaud() {
        return nmPlanSaud;
    }

    public void setNmPlanSaud(String nmPlanSaud) {
        this.nmPlanSaud = nmPlanSaud;
    }

    @XmlTransient
    public Collection<AmTbMediPlanSaud> getAmTbMediPlanSaudCollection() {
        return amTbMediPlanSaudCollection;
    }

    public void setAmTbMediPlanSaudCollection(Collection<AmTbMediPlanSaud> amTbMediPlanSaudCollection) {
        this.amTbMediPlanSaudCollection = amTbMediPlanSaudCollection;
    }

    public AmTbConvMedi getCdConvMedi() {
        return cdConvMedi;
    }

    public void setCdConvMedi(AmTbConvMedi cdConvMedi) {
        this.cdConvMedi = cdConvMedi;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cdPlanSaud != null ? cdPlanSaud.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AmTbPlanSaud)) {
            return false;
        }
        AmTbPlanSaud other = (AmTbPlanSaud) object;
        if ((this.cdPlanSaud == null && other.cdPlanSaud != null) || (this.cdPlanSaud != null && !this.cdPlanSaud.equals(other.cdPlanSaud))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.agenda.model.entity.AmTbPlanSaud[ cdPlanSaud=" + cdPlanSaud + " ]";
    }
    
}
